@echo off
echo 正在编译WebView2浏览器项目...

REM 尝试使用不同的MSBuild路径
if exist "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" WebView2Project.csproj /p:Configuration=Debug /verbosity:minimal
) else if exist "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" WebView2Project.csproj /p:Configuration=Debug /verbosity:minimal
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" (
    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" WebView2Project.csproj /p:Configuration=Debug /verbosity:minimal
) else (
    echo 未找到MSBuild，尝试使用dotnet build...
    dotnet build WebView2Project.csproj
)

if %ERRORLEVEL% EQU 0 (
    echo 编译成功！
    echo 正在启动WebView2浏览器...
    start "" "bin\Debug\WebView2Project.exe"
) else (
    echo 编译失败，错误代码: %ERRORLEVEL%
    pause
) 